﻿using AutoMapper;
using Customer.API.Applcation.Command.ProcurementCommand;
using Customer.Domain;
using Customer.Infrstructre.ProcurementManager;
using MediatR;
using NPOI.SS.Formula.PTG;

namespace Customer.API.Applcation.CommandHandlers.ProcurementCommandHandler
{
    public class ProcurementAddCommandHandler : IRequestHandler<ProcurementAddCommand, int>
    {

        IProcurementRepository rRep;
        IMapper mapper;

        public ProcurementAddCommandHandler(IProcurementRepository rRep, IMapper mapper)
        {
            this.rRep = rRep;
            this.mapper = mapper;
        }

        public async Task<int> Handle(ProcurementAddCommand request, CancellationToken cancellationToken)
        {
            return await rRep.AddAsync(mapper.Map<Procurement>(request.AddDto));

        }

    }
}
